﻿<Window x:Class="ResourceBlender_Express.WinResourcesGrid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:props="clr-namespace:ResourceBlender_Express.Properties"
    loc:WindowService.EscapeClosesWindow="True"
    Title="View Resources" WindowStartupLocation="CenterOwner"
    MinHeight="400" Height="580" MinWidth="400" Width="780"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="ApplicationCommands.Help" Executed="ShowHelp" />
        <CommandBinding Command="ApplicationCommands.New" Executed="AddElement" />
        <CommandBinding Command="ApplicationCommands.Properties" Executed="EditElement" CanExecute="CanExecuteEditElement" />
        <CommandBinding Command="NavigationCommands.Refresh" Executed="RefreshResources" />
        <CommandBinding Command="ApplicationCommands.Delete" Executed="DeleteElement" CanExecute="CanExecuteDeleteElement" />
        <CommandBinding Command="loc:ResourceBlenderCommands.BulkAddElements" Executed="BulkAddElements" />
        <CommandBinding Command="loc:ResourceBlenderCommands.FilterGrid" Executed="FilterGrid" />
        <CommandBinding Command="loc:ResourceBlenderCommands.AutoTranslate" Executed="ShowAutoTranslate" />
        <CommandBinding Command="loc:ResourceBlenderCommands.CreateVariant" Executed="ShowCreateVariant" />
        <CommandBinding Command="loc:ResourceBlenderCommands.ShowDuplicates" Executed="ShowDuplicates" />
        <CommandBinding Command="loc:ResourceBlenderCommands.ShowUnused" Executed="ShowUnused" />
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Command="loc:ResourceBlenderCommands.BulkAddElements" Gesture="Ctrl+Shift+B" />
    </Window.InputBindings>
    <Window.Resources>
        <Image x:Key="AddElement_16" Source="pack://application:,,,/Resources/images/doc_add_16.png" />
        <Image x:Key="AddElementStack_16" Source="pack://application:,,,/Resources/images/doc_add_stack_16.png" />
        <Image x:Key="EditElement_16" Source="pack://application:,,,/Resources/images/doc_edit_16.png" />
        <Image x:Key="DeleteElement_16" Source="pack://application:,,,/Resources/images/doc_delete_16.png" />
        <props:Settings x:Uid="props:Settings_1" x:Key="settings" />
    </Window.Resources>
    <DockPanel DataContext="{StaticResource settings}">
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Automatic Translation" Command="loc:ResourceBlenderCommands.AutoTranslate" />
                <MenuItem Header="Create _Variant" Command="loc:ResourceBlenderCommands.CreateVariant" />
                <MenuItem Header="_Duplicate Resources" Command="loc:ResourceBlenderCommands.ShowDuplicates" />
                <MenuItem Header="_Unused Resources" Command="loc:ResourceBlenderCommands.ShowUnused" />
                <MenuItem Header="E_xit" Command="ApplicationCommands.Close" />
            </MenuItem>
            <MenuItem Header="_Element">
                <MenuItem Header="_Bulk Add Elements" Icon="{StaticResource AddElementStack_16}" Command="loc:ResourceBlenderCommands.BulkAddElements" />
                <MenuItem Header="_New Element" Icon="{StaticResource AddElement_16}" Command="ApplicationCommands.New" />
                <MenuItem Header="_Edit Element" Icon="{StaticResource EditElement_16}" Command="ApplicationCommands.Properties" />
                <MenuItem Header="_Delete Element" Icon="{StaticResource DeleteElement_16}" Command="ApplicationCommands.Delete" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="Translating an Application" Command="ApplicationCommands.Help" />
            </MenuItem>
        </Menu>
        <StatusBar DockPanel.Dock="Bottom" Height="24">
            <StatusBarItem x:Name="lblStatus" Visibility="Hidden">Loading</StatusBarItem>
            <StatusBarItem>
                <ProgressBar x:Name="prgStatus" IsIndeterminate="True" />
            </StatusBarItem>
        </StatusBar>
        <ToolBar DockPanel.Dock="Top" Height="75">
            <loc:SplitButton Style="{StaticResource SplitButton}" MainButtonLocation="Left">
                <loc:SplitButton.Button>
                    <loc:ImageButton x:Name="btnResources" Command="ApplicationCommands.New" Text="Add" Image="Resources/images/add_32.png" ToolTip="Add Element" Style="{StaticResource ToolBarButton}" />
                </loc:SplitButton.Button>
                <loc:SplitButton.MenuButton>
                    <loc:MenuButton MenuLocation="Bottom" ToolTip="Add Element">
                        <loc:MenuButton.Menu>
                            <ContextMenu>
                                <MenuItem Header="Bulk Add Elements" Command="loc:ResourceBlenderCommands.BulkAddElements" />
                            </ContextMenu>
                        </loc:MenuButton.Menu>
                    </loc:MenuButton>
                </loc:SplitButton.MenuButton>
            </loc:SplitButton>
            <loc:ImageButton x:Name="btnEdit" Command="ApplicationCommands.Properties" Text="Edit" Image="pack://application:,,,/Resources/images/edit_32.png" ToolTip="Edit Element" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton x:Name="btnDelete" Command="ApplicationCommands.Delete" Text="Delete" Image="pack://application:,,,/Resources/images/delete_32.png" ToolTip="Delete Element" Style="{StaticResource ToolBarButton}" />
            <Separator />
            <ToggleButton x:Name="btnFilters" ToolTip="Toggle Filters Panel">
                <ToggleButton.IsChecked>
                    <Binding Path="Default.FiltersVisible" Mode="TwoWay" />
                </ToggleButton.IsChecked>
                <StackPanel>
                    <Image Source="pack://application:,,,/Resources/images/filter_32.png" />
                    <TextBlock>Filters</TextBlock>
                </StackPanel>
            </ToggleButton>
            <Separator />
            <loc:ImageButton x:Uid="loc:ImageButton_1" Command="loc:ResourceBlenderCommands.AutoTranslate" Text="Automatic Translation" Image="pack://application:,,,/Resources/images/autotranslate_24.png" ToolTip="Automatic Translation" MaxWidth="80" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton x:Uid="loc:ImageButton_2" Command="loc:ResourceBlenderCommands.CreateVariant" Text="Create Variant" Image="pack://application:,,,/Resources/images/variant_32.png" ToolTip="Create Variant" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton x:Uid="loc:ImageButton_3" Command="loc:ResourceBlenderCommands.ShowDuplicates" Text="Duplicate Resources" Image="pack://application:,,,/Resources/images/copy_24.png" ToolTip="Duplicate Resources" MaxWidth="80" Style="{StaticResource ToolBarButton}" />
            <loc:ImageButton x:Uid="loc:ImageButton_4" Command="loc:ResourceBlenderCommands.ShowUnused" Text="Unused Resources" Image="pack://application:,,,/Resources/images/unused_24.png" ToolTip="Unused Resources" MaxWidth="65"  Style="{StaticResource ToolBarButton}" />
        </ToolBar>
        <Expander DockPanel.Dock="Top" Header="Filters" Margin="6,6,6,0" Style="{StaticResource ButtonlessExpander}" IsExpanded="{Binding ElementName=btnFilters,Path=IsChecked}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="5*" />
                    <RowDefinition Height="5*" />
                    <RowDefinition Height="5*" />
                    <RowDefinition Height="5*" />
                    <RowDefinition Height="5*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Label Grid.Row="0" Grid.Column="0">Bundle Name</Label>
                <ComboBox Grid.Row="0" Grid.Column="1" x:Name="cboBundleFilter" SelectionChanged="cboFilter_SelectionChanged" />
                <TextBox Grid.Row="0" Grid.Column="2" x:Name="txtBundleFilter" TextChanged="txtFilter_TextChanged" />

                <Label Grid.Row="1" Grid.Column="0">Element Name</Label>
                <ComboBox Grid.Row="1" Grid.Column="1" x:Name="cboElementFilter" SelectionChanged="cboFilter_SelectionChanged" />
                <TextBox Grid.Row="1" Grid.Column="2" x:Name="txtElementFilter" TextChanged="txtFilter_TextChanged" />

                <Label Grid.Row="2" Grid.Column="0">Element Comment</Label>
                <ComboBox Grid.Row="2" Grid.Column="1" x:Name="cboElementCommentFilter" SelectionChanged="cboFilter_SelectionChanged" />
                <TextBox Grid.Row="2" Grid.Column="2" x:Name="txtElementCommentFilter" TextChanged="txtFilter_TextChanged" />

                <Label Grid.Row="3" Grid.Column="0">Resource Comment</Label>
                <ComboBox Grid.Row="3" Grid.Column="1" x:Name="cboResourceCommentFilter" SelectionChanged="cboFilter_SelectionChanged" />
                <TextBox Grid.Row="3" Grid.Column="2" x:Name="txtResourceCommentFilter" TextChanged="txtFilter_TextChanged" />

                <Label Grid.Row="4" Grid.Column="0">Translation for</Label>
                <DockPanel  Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" LastChildFill="True" HorizontalAlignment="Stretch">
                    <ComboBox x:Name="cboTranslationFilterLanguage" SelectionChanged="cboFilter_SelectionChanged" ItemTemplate="{StaticResource LanguageListItem}" SelectedValuePath="Key" />
                    <ComboBox x:Name="cboTranslationFilter" SelectionChanged="cboFilter_SelectionChanged" />
                    <TextBox x:Name="txtTranslationFilter" TextChanged="txtFilter_TextChanged" />
                </DockPanel>

                <CheckBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" x:Name="chkLiveFilter" Content="Filter while typing" IsChecked="{Binding Default.LiveFilter,Mode=TwoWay}" />

                <StackPanel Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal">
                    <loc:ImageButton x:Uid="loc:ImageButton_5" Margin="0,2,2,2" Image="pack://application:,,,/Resources/images/filter_16.png" ImageLocation="Left" Text="Apply Filters" MinWidth="70" Command="loc:ResourceBlenderCommands.FilterGrid" IsDefault="True">
                        <Button.Style>
                            <Style TargetType="{x:Type loc:ImageButton}" BasedOn="{StaticResource {x:Type loc:ImageButton}}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=chkLiveFilter, Path=IsChecked}" Value="True">
                                        <Setter Property="Button.IsEnabled" Value="false"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </loc:ImageButton>
                    <loc:ImageButton x:Uid="loc:ImageButton_6" Image="pack://application:,,,/Resources/images/unfilter_16.png" ImageLocation="Left" Text="Clear Filters" MinWidth="70" Command="loc:ResourceBlenderCommands.FilterGrid" CommandParameter="clear" />
                </StackPanel>
            </Grid>
        </Expander>
        <ListView x:Name="lstGrid" Margin="6" ItemsSource="{Binding}" AlternationCount="3" GridViewColumnHeader.Click="OnColumnHeaderClick" SelectionMode="Single"
                  MouseDoubleClick="lstGrid_MouseDoubleClick">
            <ListView.Resources>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Text}" />
                    <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                    <Setter Property="LineHeight" Value="12" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
                            <Setter Property="ToolTipService.IsEnabled" Value="False" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
                <DataTemplate x:Key="elementCellTemplate" DataType="elementname">
                    <TextBlock Text="{Binding Path=elementname}" ToolTip="{Binding Path=elementcomment}">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding elementcomment}" Value="">
                                        <Setter Property="ToolTipService.IsEnabled" Value="False" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </DataTemplate>
            </ListView.Resources>
            <ListView.View>
                <GridView x:Name="grdResources">
                    <GridViewColumn Header="Bundle" DisplayMemberBinding="{Binding Path=bundlename}" />
                    <GridViewColumn Header="Element" CellTemplate="{StaticResource elementCellTemplate}" />
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="_New Element" Icon="{StaticResource AddElement_16}" Command="ApplicationCommands.New" />
                    <MenuItem Header="_Edit" Icon="{StaticResource EditElement_16}" Command="ApplicationCommands.Properties" />
                    <MenuItem Header="_Delete"  Icon="{StaticResource DeleteElement_16}" Command="ApplicationCommands.Delete" />
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>
    </DockPanel>
</Window>
